<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
</head>
<body>
    登录页面
    <br/>
    邮箱<input type="text" id="email" /> <br/>
    密码<input type="password" id="password"> <br/>
    <a href="./register.html">去注册</a>
    <button id="loginBtn">登录</button>

    <script src="./jquery.3.3.1.min.js"></script>
    <script src="jquery.cookie-1.4.1.min.js"></script>
    <script>

        var loginBtn = $("#loginBtn");
        loginBtn.click(function() {
            var email = $("#email").val();
            var password = $("#password").val();
            var url = "http://local.nick.xin/api/user/login/"+email+"/" + password;
            $.get(url, function(data) {
                if (email == data) {
                    var token=$.cookie('token')
                    console.log(token);
                    $.cookie('token', token)
                    window.location.href="./welcome.html";
                } else {
                    alert("账号或密码不对");
                }
            })
        })

    </script>

</body>
</html>